<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            box-sizing: border-box;
        }
         div{
          width: 400px;
          height: 50px;
            display:flex;
            justify-content: center;
            align-items: center;
         }
        .red{
            background-color: red;
        }
        .r1{
            width: 30px;
            height:30px;
            border: 1px solid black;
            display:flex;
            justify-content: center;
            align-items: center;
            /* flex-direction: column; */
        }
        .b1{
            /* display: none; */
            width: 20px;
            height: 20px;
            background-color: rgb(255, 75, 75);
        }
       
    </style>
</head>
<body>
    <div>
        <div class="r1"><div class="r2"></div></div>
        <span>两周内自动登录</span>
    </div>
        
        
    <script>
        var r1 = document.querySelector('.r1');
        var r2 = document.querySelector('.r2');
        var a=true;
        
          r1.onclick = function(){
              if(a==true){r2.classList.add('b1');}
              else{
                r2.classList.remove('b1');
              }
            a = !a;
          }
    </script>
</body>
</html>